package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.po.DtNewsSort;
import com.xueyi.aixihu.entity.vo.ComplainRecordVo;
import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.reqeust.ComplaintReq;
import com.xueyi.aixihu.reqeust.NewsTypeReq;
import com.xueyi.aixihu.reqeust.SelectComplaintReq;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.ComplaintService;
import org.omg.PortableInterceptor.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author leiyu
 */
@RestController
public class ComplaintController extends BaseController {

    @Autowired
    private ComplaintService complaintService;

    /**
     * 条件查询投诉信息
     */
    @RequestMapping("/complaint/list")
    public BaseResponse<List<ComplainRecordVo>> getList(SelectComplaintReq req) throws SzException {
        List<ComplainRecordVo>  list = complaintService.getList(req);
        return BaseResponse.success(list);
    }

    /**
     * 统计记录数量
     */
    @RequestMapping("/complaint/statisticsTotalNumber")
    public BaseResponse<Map<String,Integer>> statisticsTotalNumber(SelectComplaintReq req) throws SzException{
        Map<String, Integer> stringIntegerMap = complaintService.statisticsTotalNumber(req);
        return BaseResponse.success(stringIntegerMap);
    }

    /**
     * 查询所有地区信息
     * @return
     * @throws SzException
     */
    @RequestMapping("/complaint/selectAllAreaInfoList")
    public BaseResponse<List<DtNewsSort>> selectAllAreaInfoList() throws SzException{
        List<DtNewsSort> dtNewsSorts = complaintService.selectAllAreaInfoList();
        return BaseResponse.success(dtNewsSorts);
    }

    /**
     * 处理投诉信息
     */
    @PostMapping("/complaint/deal")
    public BaseResponse<List<ComplaintReq>> deal(ComplaintReq complaintReq) throws SzException {
        List<ComplaintReq> list = new ArrayList<>();
        list = complaintService.deal(complaintReq);
        return BaseResponse.success(list);
    }

    /**
     * 新增投诉信息
     */
    @RequestMapping("/complaint/add")
    public BaseResponse<List<ComplaintReq>> add(ComplaintReq complaintReq) throws SzException {
        List<ComplaintReq> list = new ArrayList<>();
        list = complaintService.add(complaintReq);
        return BaseResponse.success(list);
    }
}
